package com.skwen.delivery.superdelivery.order.adapter;

import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.skwen.delivery.superdelivery.R;
import com.skwen.delivery.superdelivery.order.bean.WriteOrder;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by skwen on 2017/11/18.
 * SuperDelivery
 */

public class WriteOrderHolder extends RecyclerView.ViewHolder {

    @BindView(R.id.item_no)
    TextView mItemNo;
    @BindView(R.id.item_name)
    TextView mItemName;
    @BindView(R.id.item_phone)
    TextView mItemPhone;
    @BindView(R.id.item_address)
    TextView mItemAddress;
    @BindView(R.id.item_type)
    TextView mItemType;
    @BindView(R.id.item_weight)
    TextView mItemWeight;
    @BindView(R.id.item_pay)
    TextView mItemPay;
    @BindView(R.id.item_state)
    TextView mItemState;


    public WriteOrderHolder(View itemView) {
        super(itemView);
        ButterKnife.bind(this, itemView);
    }


    public void bindData(WriteOrder item){
        mItemNo.setText(getIfNullText(item.getId()+""));
        mItemName.setText(getIfNullText(item.getReceiveName()));
        mItemPhone.setText(getIfNullText(item.getReceicePhone()));
        mItemAddress.setText(getIfNullText(item.getReceiveAddress()));
        mItemType.setText(getIfNullText(item.getGoodsType()));
        mItemWeight.setText(getIfNullText(item.getGoodsWeight()));
        if (item.getIfReceivedPay() == 0) {
            mItemPay.setText("在线支付");
        } else if (item.getIfReceivedPay() == 1) {
            mItemPay.setText("货到付款");
        }
        mItemState.setText("待确认");
    }



    /**
     * 获取String
     */
    private String getIfNullText(CharSequence charSequence){
        if (!TextUtils.isEmpty(charSequence)){
            return charSequence.toString();
        } else return "";
    }
}
